package sphere.view;

import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;

import sphere.controller.SphereController;


public class SphereWindow extends Frame {
	
	private Panel p;
	private static final String stringRadius=new String("Rayon :"); 
	private static final String stringVolume=new String("Volume :"); 
	private static final String stringSurface=new String("Surface :"); 
	private TextField textRadius, textVolume, textSurface;
	
	public SphereWindow(String title){
		super(title);
		this.setLayout(new FlowLayout());
		addWindowListener(new MonException());
		this.p = new Panel();
		this.add(this.p);
		
		this.p.setLayout(new GridLayout(0,2,10,10));
	
		Label labelRadius=new Label(stringRadius);
		this.textRadius=new TextField(20);
		p.add(labelRadius);
		p.add(this.textRadius);
		
		
		Label labelVolume=new Label(stringVolume);
		this.textVolume=new TextField(20);
		this.textVolume.setEnabled(false);
		p.add(labelVolume);
		p.add(this.textVolume);
		
		Label labelSurface=new Label(stringSurface);
		this.textSurface=new TextField(20);
		this.textSurface.setEnabled(false);
		p.add(labelSurface);
		p.add(this.textSurface);
		
		this.pack();
		this.add(p);
		this.setVisible(true);
	
		SphereController ecouteur = new SphereController(this);
		this.textRadius.addTextListener(ecouteur);
		
		
		
	}
	
	public void setSurface(double surface){
		this.textSurface.setText(String.valueOf(surface));
	}
	public void setVolume(double volume){
		this.textVolume.setText(String.valueOf(volume));
	}

}
